<?php
declare (strict_types = 1);

namespace app\auth\service;

use app\auth\model\RoleRightLinkModel;

class RoleRightLinkService  extends BaseService
{
    public function __construct(RoleRightLinkModel $roleRightLinkModel)
    {
        $this->roleRightLinkModel = $roleRightLinkModel;
    }

    public function model(){
        return $this->roleRightLinkModel;
    }

    public function list(array $where = [] , array $limit = [], array $sort= []){
        $limit = check_limit($limit);
        $sort = check_sort($sort);
        return $this->roleRightLinkModel->where($where)->limit($limit['page'],$limit['pagesize'])->order($sort[0],$sort[1])->select();
    }

    public function count(array $where = [],array $whereIn = []){
        $model = $this->roleRightLinkModel;
        $model = $model->where($where);
        if(!empty($whereIn)) $model->whereIn($whereIn[0],$whereIn[1]);
        return $model->count();
    }

    public function select(array $where = [],array $fields = ['*']){
        return $this->roleRightLinkModel->field($fields)->where($where)->select();
    }

    public function insertGetId(array $data = []){
        return $this->roleRightLinkModel->insertGetId($data);
    }
}
